#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>


int rfun(int n)
{
    if (n > 0)
    {
        return rfun(n - 1) * n;
    }
    
}
int fun(int n)
{
    if (n < 0) 
        return -1;
    int i = 1;
    int s = 1;
    for (i = 1; i <= n; i++)
    {
        s *= i;
    }
    return s;
}
int main(void)
{
    int a, b;
    printf("Input a,b:");
    int m = 0;
    scanf("%d %d", &a, &b);
    if (a < 0 || b < 0)
        return -1;
        if (a > b)
        {
            int i = 0;
            i = a;
            a = b;
            b = i;
            for (int i = a; i<= b; i++)
            {
                m += fun(i);
            }
        }
        else
        {
            for (int i = a; i <= b; i++)
            {
                m += fun(i);
            }
        }
        printf("%d\n", m);

        int x, y;
        printf("Input x,y:");
        scanf("%d %d", &x, &y);
        if (x < 0 || y < 0)
        {
            return -1;
        }
        int n = 0;
        if (x > y)
        {
            int j = 0;
            j = x;
            x = y;
            y = j;
            for (int i = x; i <= y; i++)
            {
                n += rfun(i);
            }
        }
        else
        {
            for (int i = x; i <= y; i++)
            {
                n += rfun(i);
            }
        }
        printf("%d\n", n);
        return 0;
}
